package com.jumper.mydemo.aop;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect 
public class LogAspect {
    private static final Logger logger = LogManager.getLogger(LogAspect.class);

    @Pointcut("execution(* com.jumper..*Service.*(..))")
    private void log() {}

    @Before("log()")
    public void before(JoinPoint jp) {
        logger.info("before, {}", jp.getSignature());
    }

    @After("log()")
    public void after(JoinPoint jp) {
        logger.info("after, {}", jp.getSignature());
    }
}
